import { ResPage, User } from "@/api/interface/index";
import { PORT1 } from "@/api/config/servicePort";
import http from "@/api";

/**
 * @name 用户管理模块
 */
// 获取用户列表
export const getUserList = (params: User.ReqUserParams) => {
  //
  console.log(params);
  // return http.post<ResPage<User.ResUserList>>(PORT1 + `/user/list`, params);
  return new Promise(resolve => {
    let res = {
      data: {
        list: [
          {
            id: 1,
            name: 1,
            roleId: 1,
            mobile: 1,
            password: 1,
            avatarUrl: 1,
            sex: 1,
            province: 1,
            city: 1,
            country: 1,
            email: 1,
            wechat: 1,
            totalIntegral: 1,
            iceIntegral: 1,
            status: 1,
            token: 1,
            expired: 11,
            remark: 1,
            isDelete: 1,
            gmt_create: 1,
            gmtModified: 1,
            createBy: 1,
            modifiedBy: 1
          },
          {
            id: 2,
            name: 1,
            roleId: 1,
            mobile: 1,
            password: 1,
            avatarUrl: 1,
            sex: 2,
            province: 1,
            city: 1,
            country: 1,
            email: 1,
            wechat: 1,
            totalIntegral: 1,
            iceIntegral: 1,
            status: 1,
            token: 1,
            expired: 11,
            remark: 1,
            isDelete: 1,
            gmt_create: 1,
            gmtModified: 1,
            createBy: 1,
            modifiedBy: 1
          }
        ],
        total: 1,
        pageNum: 1,
        pageSize: 2
      }
    };
    resolve(res);
  });
};

// 获取树形用户列表
export const getUserTreeList = (params: User.ReqUserParams) => {
  return http.post<ResPage<User.ResUserList>>(PORT1 + `/user/tree/list`, params);
};

// 新增用户
export const addUser = (params: { id: string }) => {
  return http.post(PORT1 + `/user/add`, params);
};

// 批量添加用户
export const BatchAddUser = (params: FormData) => {
  return http.post(PORT1 + `/user/import`, params);
};

// 编辑用户
export const editUser = (params: { id: string }) => {
  return http.post(PORT1 + `/user/edit`, params);
};

// 删除用户
export const deleteUser = (params: { id: string[] }) => {
  return http.post(PORT1 + `/user/delete`, params);
};

// 切换用户状态
export const changeUserStatus = (params: { id: string; status: number }) => {
  return http.post(PORT1 + `/user/change`, params);
};

// 重置用户密码
export const resetUserPassWord = (params: { id: string }) => {
  return http.post(PORT1 + `/user/rest_password`, params);
};

// 导出用户数据
export const exportUserInfo = (params: User.ReqUserParams) => {
  return http.download(PORT1 + `/user/export`, params);
};

// 获取用户状态字典
export const getUserStatus = () => {
  return http.get<User.ResStatus[]>(PORT1 + `/user/status`);
};

// 获取用户性别字典
export const getUserGender = () => {
  return http.get<User.ResGender[]>(PORT1 + `/user/gender`);
};

// 获取用户部门列表
export const getUserDepartment = () => {
  return http.get<User.ResDepartment[]>(PORT1 + `/user/department`);
};

// 获取用户角色字典
export const getUserRole = () => {
  return http.get<User.ResRole[]>(PORT1 + `/user/role`);
};
